<template>
  <div class="top_bar">
    <div class="info">
      <img
        :src="image"
        alt=""
        @click="large(image)"
      />
      <h3 class="focus-in-expand">{{ info.name }}</h3>
    </div>
    <div class="contact">联系我<img
        src="../assets/QRcode.png"
        alt=""
      /></div>
    <Masks
      ref="childRef"
      :bigPicture="bigPicture"
      :isMask="isMask"
      @changeMaskState="changeMaskState"
    />
  </div>
</template>

<script>
import { getUserInfo } from '../api/user'
import Masks from '@/components/Masks.vue'
export default {
  components: {
    Masks
  },
  data() {
    return {
      info: {},
      baseURL: this.baseURL,
      image: require('../assets/headerPic3.png'),
      bigPicture: '',
      isMask: false
    }
  },
  async created() {
    const res = await getUserInfo()
    this.info = res.data.data
    this.image = `${this.baseURL}/uploads/${this.info.photo}`
  },
  methods: {
    changeMaskState() {
      this.isMask = false
    },
    large(v) {
      this.bigPicture = v
      this.isMask = true
      this.$refs.childRef.enlarge()
    }
  }
}
</script>

<style lang="scss" scoped>
// 宽度大于1201px时
@media screen and (min-width: 1201px) {
  .top_bar {
    width: 1200px;
    margin: 20px auto;
  }
}

// 宽度小于1200px时
@media screen and (max-width: 1200px) {
  .top_bar {
    margin: 20px 40px;
  }
}

@media only screen and (max-width: 480px) {
  .top_bar {
    margin: 8px 15px;
  }
  body .top_bar .info {
    height: 60px;
  }
  body .top_bar .contact {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    // width: calc(100%-76px);
    height: 30px;
    z-index: 9999;
    border-radius: 0px;
  }
  body .top_bar .info img {
    width: 60px;
    height: 60px;
  }
  .contact img {
    top: -120px;
    left: 50%;
    transform: translateX(-50%);
  }
}

.top_bar {
  display: flex;
  //   background: green;
  justify-content: space-between;
  //   max-width: 1200px;
  .info {
    height: 101px;
    width: 300px;
    display: flex;
    overflow: visible;
    border-radius: 8px;
    box-shadow: 6px 6px 12px #c5c5c5, -6px -6px 12px #ffffff;
    img {
      width: 101px;
      height: 101px;
      border-radius: 3px;
      box-shadow: 0 0 10px #a2a0a0;
    }
    h3 {
      // margin: 20px 0 0 15px;
      margin: 20px auto 15px;
    }
  }
  .contact {
    cursor: pointer;
    border-radius: 8px;
    box-shadow: 6px 6px 12px #c5c5c5, -6px -6px 12px #ffffff;
    line-height: 30px;
    text-align: center;
    width: 120px;
    // padding: 0 38px;
    background: #e01109;
    color: #fff;
    height: 30px;
    margin-top: 30px;
    img {
      display: none;
      position: absolute;
      width: 120px;
      z-index: 999;
      // box-shadow: 0 0 10px #a2a0a0;
      border-radius: 8px;
      box-shadow: 6px 6px 12px #c5c5c5, -6px -6px 12px #ffffff;
    }
  }
  .contact:hover img {
    display: block;
  }
}
.focus-in-expand {
  animation: focus-in-expand 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}
@keyframes focus-in-expand {
  0% {
    letter-spacing: -0.5em;
    filter: blur(12px);
    opacity: 0;
  }
  100% {
    filter: blur(0px);
    opacity: 1;
  }
}
</style>
